package com.Monica.dao;

import com.Monica.pojo.User;
import com.Monica.utils.JDBCUtil;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.ResultSetHandler;
import org.apache.commons.dbutils.handlers.BeanHandler;
import org.apache.commons.dbutils.handlers.ScalarHandler;

import java.sql.Connection;
import java.sql.SQLException;

public class UserDAOImp implements UserDAO {
    private QueryRunner queryRunner = new QueryRunner(JDBCUtil.getDataSource());

    @Override
    public boolean insert(User data) {

        return false;
    }

    @Override
    public boolean delete(String id) {

        return false;
    }

    @Override
    public boolean update(User newData) {

        return false;
    }

    @Override
    public User select(String id) {
        User query = null;
        Connection connection = JDBCUtil.getConnection();
        String sql = "SELECT * FROM t_user WHERE username = ?";
        try {
            query = queryRunner.query(sql, new BeanHandler<User>(User.class), id);
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return query;
    }

}

